
import '../services/Storage.dart';
import 'dart:convert';

class UserServices {
  List _userInfo;
  List get userInfo => _userInfo;
  static getUserInfo() async{
    List userInfo;
    try{
      List userInfoData = json.decode(await Storage.getString('userinfo'));
      userInfo = userInfoData;
    }catch(e){
      userInfo = [];
    }
    print(userInfo);
    return userInfo;
  }
  static getUserLoginState() async{
    var user = await UserServices.getUserInfo();
    if(user.length > 0 && user[0]['username'] != ''){
      return true;
    }
    return false;
  }
  static loginOut(){
     Storage.remove('userinfo');
  }
}